home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / showdevs.zip / SHOWDEVS.DOC < prev    next >
Text File  |  1989-03-14  |  4KB  |  82 lines

  1.  
  2. Show MS-DOS Device Drivers in a System.
  3.  
  4.    Written by John Porter, Blue Flamingo Software, March 1989.
  5.    This material is submitted to the Public Domain, inasmuch as
  6.    Microsoft Corporation reserves the rights to all of its proprietary
  7.    information and copyrighted material.
  8.  
  9. Files included:
  10.    SHOWDEVS.DOC
  11.    SHOWDEVS.C
  12.    GETLOL.C
  13.    GETLOL.ASM
  14.    SHOWDEVS.MK
  15.    SHOWDEVS.EXE
  16.  
  17. The purpose of this program is to ouput a list of the device drivers
  18. currently active in a (MS-DOS) system.
  19.  
  20. Each device driver consists of a header (an eighteen-byte structure), and bunch
  21. of other stuff (code). The FIRST item in the header is a pointer to the header
  22. of the next driver in the chain.  Other items in the header are the device
  23. attribute word; the name of the device; the offsets of the strategy and
  24. interrupt routines (the code that implements the driver).
  25.  
  26. Thus it is easy to display the info for a driver and to find the next driver
  27. in the chain; the trick is to find the FIRST driver.  There are two ways to
  28. do this.  One utilizes the fact that the first driver in the chain is ALWAYS
  29. the NUL device (at least through MS-DOS version 3.3).  This method searches
  30. from the bottom of ram for the name 'NUL'; and then assumes that this is in
  31. the header of the first driver.  This method has the disadvantages of being
  32. dependent on the fact that the first driver is always named NUL, and by
  33. searching willy-nilly for text, is hardly failsafe.  Of course, more validity
  34. checks could be added, at the expense of program complexity.
  35.  
  36. Another method is to utilize the fact that the device driver chain is
  37. maintained by DOS in memory just after the List of Lists; this is the structure
  38. which DOS uses to locate other global information, such as the head of the
  39. Memory Control Block chain, and the head of the Disk Block chain.  Some
  40. complexity is added by the fact that the length of the List of Lists is
  41. different for versions 2.xx and 3.xx (and probably 4.xx also).  The length is
  42. 17h for versions 2.xx, and 22h for versions 3.xx.  I have assumed in my sample
  43. program that the DOS version is 3.xx. You may change this, or a routine may
  44. be easily added to determine which version of DOS the program is running under.
  45. To find the List of Lists easily, call the undocumented DOS function 52h.
  46. This returns the address of the List of Lists in ES:BX.  The disadvantage of
  47. this is obvious: Microsoft always threatens to change these things without
  48. notice.  (Some of us DO notice.)  However, if you're running MS-DOS version
  49. 2.xx or 3.xx, function 52h works.  Anyone know about 4.xx, or OS\2?
  50.  
  51. The last driver in the chain uses a signed value of -1 in the
  52. Pointer-to-Next-Driver field of the header, to indicate that it is the last.
  53.  
  54. The main program is in SHOWDEVS.C; the function getlol() (Get List of Lists)
  55. is defined in two ways: a C version and an assembler version, in GETLOL.C
  56. and in GETLOL.ASM, respectively.  You can use SHOWDEVS.MK to create the file
  57. SHOWDEVS.EXE.  This makefile assumes that GETLOL.ASM is going to be used.
  58.  
  59. Note that SHOWDEVS.EXE as supplied with this package should only be run if you
  60. know that you are using MS-DOS version 3.xx.
  61.  
  62.  
  63. I used Microsoft C v. 5.1, and Microsoft Macro Assembler v. 5.1.
  64. N.B. copyrights held by Microsoft Corporation.
  65.  
  66. For more detailed information on the structure and operation of device drivers,
  67. try these books:
  68.  
  69.    Advanced MS-DOS, Ray Duncan, Microsoft Press 1986,1988
  70.  
  71.    MS-DOS Developer's Guide, The Waite Group,
  72.      Howard Sams and Co., 1988
  73.  
  74. Credit and thanks go to The Waite Group and Howard Sams & Co. for
  75.   documenting the undocumented.
  76.  
  77. If you have any questions, problems, or comments, you may reach me at:
  78.  
  79. CompuServe  70441,214
  80. Genie       J.PORTER5
  81.  
  82.